import React, { useState } from 'react';
import {textApi,postTest} from '../../api'
import {
    Form,
    Input,
    Tooltip,
    Icon,
    Cascader,
    Select,
    Row,
    Col,
    Checkbox,
    Button,
    AutoComplete,
  } from 'antd';
  
  class RegistrationForm extends React.Component {
    constructor(props){
        super(props)
        this.state={
            userName:'',
            passWord:'',
            nickName:'',
            passWordAgain:''

        }
    }

     InputChange = (e) =>{
        const target = e.target;
        const name = target.name;
        const value = target.type === 'checkbox' ? target.checked : target.value;
        this.setState({
            [name]:value
        })
        
       
    }

    closedPop = () =>{
        this.props.ishow()
    }

    singUpInfor = () =>{
        const {userName,passWord,passWordAgain,nickName} = this.state;
        let _obj = {
            userName,
            nickName,
            passWord
        }
        postTest('/singUp',_obj).then((res) =>{
            console.log(res);
            
        })
    }
  
    render() {
        const {userName,passWord,passWordAgain} = this.state;
        return (
            <div className="fixBg">
                <div className="popContent">
                    <div className="infors singUp_infors">
                        <Icon onClick={this.closedPop} className="closed" type="close" />
                        <h3> <span className="iconfont icon-yuncloud259 logos"></span> 注册新账号</h3>
                        <Input name="userName" className="firstInput" onChange={this.InputChange} type="text" value={userName} placeholder="亲，你的账户" />
                        <Input name="nickName" className="firstInput" onChange={this.InputChange} type="text" value={userName} placeholder="亲，你的外号" />
                        <Input.Password name="passWord" password="true" type="password" onChange={this.InputChange} value={passWord} placeholder="亲，你的密码" />
                        <Input.Password name="passWordAgain" password="true" type="password" onChange={this.InputChange} value={passWordAgain} placeholder="亲，再来一次" />
                        <Button onClick={this.singUpInfor}  type="primary">注 册</Button>
                    </div>
                </div>
            </div>
        )
    }
  }
  
  export default RegistrationForm
   